class Web:
    def index(self):
        print("我是首页")

    def user(self):
        print("我是用户页面")

    def page_404(self):
        print("404页面")

web = Web()

def to_page():
    page = input("请输入想去的页面：")
    if hasattr(web, page):
        getattr(web, page)()
    else:
        web.page_404()

to_page()